<template>
  <view :class="{ Modal: true, ModalShow: visible }" @click.self="closeHandler">
    <slot v-if="visible" />
  </view>
</template>
<script lang="ts">
import ProjectUtil from '@/utils/ProjectUtil';
import Vue from '@/utils/Vue';
import { PropType } from 'vue';

interface IData {}

export default Vue.extend({
  data(): IData {
    return {};
  },
  components: {},
  props: {
    visible: Boolean,
    onClose: Function as PropType<() => void>,
  },
  emits: ['close'],
  methods: {
    closeHandler() {
      ProjectUtil.emit(this, 'close');
    },
  },
});
</script>
<style lang="less" scoped>
.Modal {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  z-index: 9;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  transition: all 0.3s;

  &.ModalShow {
    pointer-events: all;
    backdrop-filter: blur(7px);
    background: rgba(0, 0, 0, 0.7);
  }
}
</style>
